import Vue from 'vue'
import VueRouter from 'vue-router'
import routes from '@/router/routes'
import { getToken } from '@/utils/storage'

Vue.use(VueRouter)

const router = new VueRouter({
  routes
  
}) 
//添加路由守卫
const whiteList = ['/login', '/register']
const token = getToken
router.beforeEach((to, from, next) => {
  if (token) {
    next()
  } else {
    whiteList.includes(to.path) ? next() : next('/login')
  }
})





export default router